package org.example;

import org.example.segmentation.Range;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;

public class Main {

  /**
   *
   * @param args
   * "INPCASE.HOSPITAL_RECORD" "G01_INPCASE.HOSPITAL_RECORD_TEMP" "create_time >= '20210301000000' and create_time < '20210901000000'"
   * @throws IOException
   * @throws SQLException
   */
  public static void main(String[] args) throws IOException, SQLException {
    System.out.println("version 1.00");
    if (args.length < 4) {
      System.out.println("Usage: java Main <sourceTable> <targetTable> <condition> <batchSize>");
      return;
    }

    String sourceTable = args[0];
    String targetTable = args[1];
    String condition = args[2];
    int batchSize = Integer.parseInt(args[3]);

    try (Connection sourceConn = DriverManager.getConnection("jdbc:oracle:thin:@//172.16.30.64:1521/emrdg", "ggate", "bdyyggate");
         Connection targetConn = DriverManager.getConnection("jdbc:oracle:thin:@//172.20.5.70:1521/orcl", "ggate", "bdyyggate")) {
      DataTransfer transfer = new DataTransfer();
      transfer.transferData(sourceConn, targetConn, sourceTable, targetTable, condition, batchSize);
    }
  }
}